//
//  GKBMainController.h
//  GKBHouse
//
//  Created by  on 12-6-19.
//  Copyright (c) 2012年 __MyCompanyName__. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "ExFrame.h"
#import "HouseButton.h"
#import "DeviceView.h"
#import "RoomView.h"
#import "Global1.h"
#import "GKBNavigationBar.h"

//#define kMainFrameTop 40
//#define kMainFrameHeight (320 - kMainFrameTop - 12)
//
//#define kHouseMenuWidth 80
//#define kHouseMenuHeight ((kMainFrameHeight/4))
//
//#define kDeviceMenuWidth (480 - kHouseMenuWidth)

#define kMainFrameTop (kTopBarHeight+10.0f)

#define kMainFrameHeight (320 - kMainFrameTop - 12)

#define kHouseMenuWidth 80
#define kHouseMenuHeight ((kMainFrameHeight/4))

#define kDeviceMenuWidth (DEVICE_HEIGHT - kHouseMenuWidth)

BOOL mainview_autoLogin;

typedef NS_ENUM(NSInteger, RefreshState)
{
    RefreshStateStart,
    RefreshStateLoading,
    RefreshStateEnd,
};

@interface GKBMainController : UIViewController<UIScrollViewDelegate>
{
    ASINetworkQueue *networkQueue;
    NSMutableArray *_houseArray;
    UIScrollView *houseMenuScrollView;
    UIImageView *_upArrow;
    UIImageView *_downArrow;
    UIScrollView *devicesScrollView;
    NSMutableArray *_scrollPages;

    NSMutableArray * _pageViews;
    BOOL bPageRefreshed;
    
    RoomView *roomView;
    
}
@property (retain) NSTimer *equStateTimer;
@property (retain)NSMutableArray *equipments;
@property (retain)NSMutableArray *areaEquipments;
@property (retain)NSMutableArray *roomNames;
@property (retain)NSMutableArray *roomNamess;
@property (retain)NSMutableDictionary *rooms;
@property (retain)NSMutableDictionary *roomss;
@property (retain)NSMutableArray *sceneArray;
@property (retain)NSMutableArray *videoArray;//跳转去视频
@property (retain)NSMutableArray *protectArray;
@property (assign) id updateTarget;
@property (assign) SEL updateAction;
@property (assign)RefreshState state;
@property (assign)NSInteger refreshTime;//刷新次数

@property (retain)NSMutableArray *cameraGroup;

@property (retain)NSMutableDictionary *cameraInfoArrayDic;

@property (retain)NSDictionary *cameraInfo;

+ (UIView *)mainView;
+ (void)setMainView:(UIView *)view;
+ (id)mainCtr;
+ (void)setMainCtr:(id)ctr;
+ (void)refreshDevices;//刷新设备数据

- (void)dismissView;

- (void)loadList;

#pragma mark - timer

+ (void)postStartRefresh;
+ (void)postStopRefresh;

#pragma mark - initView
- (void)initTitle;
- (void)addHouseMenu:(NSInteger)index title:(NSString *)title image:(NSString *)img selected:(NSString *)selectedImg devices:(NSArray*)array;
- (void)initRightFrame;
- (void)initDevicesTwo;
- (void)initDevices;
- (NSInteger)pageCount;
- (void)houseAction:(HouseButton *)but;
- (void)houseOutsize:(id)sender;
- (void)openRoom:(HouseButton*)house;
- (void)refreshRoomView;
- (void)closeRoom;

- (void)scrollToPage:(NSInteger)page animated:(BOOL)animated;
- (void)initScene;
- (void)initRoomsMenu;
#pragma mark - 电器设置数据
- (void)equipmentList;
- (void)equipmentListEnd:(NSDictionary *)dic;

#pragma mark - 区域数据
- (void)areaEquipmentList;
- (void)areaEquipmentListEnd:(NSDictionary *)dic;

#pragma mark - 电器设备开关状态
- (void)equipmentStateWidthTip;
- (void)equipmentStateWidthTipEnd:(NSDictionary *)dic;

- (void)equipmentState;
- (void)equipmentStateEnd:(NSDictionary *)dic;
- (void)setRoomsState:(NSArray *)states;
- (void)refreshDevicesState;
- (void)updateStateByNet;
- (void)updateStateByNetTarget:(id)target action:(SEL)action;

+ (void)updateEqu:(NewEquipment *)euq button:(UIButton *)but states:(NSArray*)states;
@end
